package com.ace.token.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
import javax.validation.Validator;

/**
 * 验证器配置类
 * @Author
 * @Date 2018年07月02日 下午6:22
 */
@Configuration
public class ValidatorConfiguration {

    @Autowired
    private ResourceBundleMessageSource resourceBundleMessageSource;

    @Bean
    public Validator getValidator() throws Exception {
        LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
        validator.setValidationMessageSource(resourceBundleMessageSource);
        return validator;
    }


}
